package cn.java75.aop2.intercep;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Service;

/**
 * @author oldliu
 * @since 1.0
 */
@Service
@Aspect
public class MyInterceptor2 {
    @Around("within(cn.java75.aop2.serivce..*)")
    public Object lanjie(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.nanoTime();
        try {
            return joinPoint.proceed();
        } finally {
            long end = System.nanoTime();
            System.out.println("方法:" + joinPoint.getSignature().getName() + "执行花费了：" + (end - start) + "纳秒");
        }
    }
}
